<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>运维月报 - {{ report_month }}</title>
    <style>
        body {
            font-family: "Microsoft YaHei", "SimSun", sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f9f9f9;
            color: #333;
            line-height: 1.6;
        }

        .report-container {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border: 1px solid #eee;
        }

        .header {
            text-align: center;
            margin-bottom: 30px;
            border-bottom: 2px solid #000;
            padding-bottom: 20px;
        }

        .header h1 {
            font-size: 28px;
            margin: 10px 0;
            font-weight: bold;
        }

        .header h2 {
            font-size: 20px;
            margin: 5px 0;
            color: #555;
        }

        .section {
            margin-bottom: 30px;
        }

        .section-title {
            font-size: 18px;
            font-weight: bold;
            margin: 20px 0 15px 0;
            padding-left: 10px;
            border-left: 4px solid #0066cc;
            color: #0066cc;
        }

        .conclusion-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-top: 10px;
        }

        .conclusion-item {
            background: #f5f9ff;
            padding: 12px;
            border-radius: 4px;
            border: 1px solid #d0e0f0;
        }

        .conclusion-label {
            font-size: 14px;
            color: #666;
        }

        .conclusion-value {
            font-size: 18px;
            font-weight: bold;
            color: #000;
            margin-top: 4px;
        }

        .conclusion-value.down {
            color: #d32f2f;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin: 10px 0;
        }

        th, td {
            border: 1px solid #ddd;
            padding: 10px;
            text-align: center;
        }

        th {
            background-color: #f0f5ff;
            font-weight: bold;
        }

        .highlight {
            color: #d32f2f;
            font-weight: bold;
        }

        .chart-placeholder {
            height: 150px;
            background: #fafafa;
            border: 1px dashed #ccc;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #888;
            margin: 10px 0;
            font-size: 14px;
        }

        .footer-note {
            font-size: 12px;
            color: #888;
            text-align: center;
            margin-top: 30px;
            padding-top: 15px;
            border-top: 1px solid #eee;
        }
    </style>
</head>
<body>
<div class="report-container">
    <!-- 头部 -->
    <div class="header">
        <h1>{{ company_name }}运维报告</h1>
        <h2>{{ report_year }}年{{ report_month }}月月报</h2>
    </div>

    <!-- 一、结论与建议 -->
    <div class="section">
        <div class="section-title">一、结论与建议</div>

        <!-- 1. 用能分析 -->
        <div class="conclusion-grid">
            <div class="conclusion-item">
                <div class="conclusion-label">电 (MWh)</div>
                <div class="conclusion-value">{{ electricity_usage }}</div>
                <div class="conclusion-value down">环比 {{ electricity_change }}%</div>
            </div>
            <div class="conclusion-item">
                <div class="conclusion-label">水 (m³)</div>
                <div class="conclusion-value">{{ water_usage }}</div>
                <div class="conclusion-value">环比 --%</div>
            </div>
            <div class="conclusion-item">
                <div class="conclusion-label">燃气 (t)</div>
                <div class="conclusion-value">{{ gas_usage }}</div>
                <div class="conclusion-value">环比 --%</div>
            </div>
            <div class="conclusion-item">
                <div class="conclusion-label">电量平均峰谷比</div>
                <div class="conclusion-value">--%</div>
            </div>
        </div>
        <p style="margin-top: 10px; color: #d32f2f;">
            本月，用电最多的设备为<span class="highlight">{{ top_electricity_device }}</span>，请关注！
        </p>

        <!-- 2. 变压器监控分析 -->
        <div class="conclusion-grid" style="margin-top: 15px;">
            <div class="conclusion-item">
                <div class="conclusion-label">变压器平均负载率 (%)</div>
                <div class="conclusion-value">{{ avg_transformer_load }}</div>
            </div>
            <div class="conclusion-item">
                <div class="conclusion-label">平均负载率最高 (%)</div>
                <div class="conclusion-value">{{ max_transformer_load }}<br>{{ max_transformer_name }}</div>
            </div>
            <div class="conclusion-item">
                <div class="conclusion-label">平均负载率最低 (%)</div>
                <div class="conclusion-value">{{ min_transformer_load }}<br>{{ min_transformer_name }}</div>
            </div>
        </div>
        <p style="margin-top: 10px;">
            本月变压器功率因数均大于0.9，请继续保持！
        </p>

        <!-- 3. 事件分析 -->
        <div style="margin-top: 15px;">
            <p>本月共发生 <span class="highlight">{{ total_events }}</span> 条事件，其中事故事件与告警事件 <span
                    class="highlight">{{ alert_events }}</span> 条。</p>
            <p>事件类型占比最高的是 <span class="highlight">{{ top_event_type }}</span>。</p>
            <p>事件发生次数最多的设备是 <span class="highlight">{{ top_event_device }}</span>，请关注！</p>
            <p>本月实际发生事件总数为 <span class="highlight">{{ total_events }}</span> 条，已处理事件：<span
                    class="highlight">{{ handled_events }}</span> 条，事件跟进处理情况评级为：<span class="highlight">{{ event_rating }}</span>。
            </p>
        </div>

        <!-- 运维工单统计 -->
        <table style="margin-top: 15px;">
            <tr>
                <th>总运维次数</th>
                <th>巡检工单</th>
                <th>维保工单</th>
                <th>预试工单</th>
                <th>检修工单</th>
            </tr>
            <tr>
                <td>{{ total_maintenance }}</td>
                <td>{{ inspection_orders }}</td>
                <td>{{ maintenance_orders }}</td>
                <td>{{ pretest_orders }}</td>
                <td>{{ repair_orders }}</td>
            </tr>
        </table>
        <p style="margin-top: 10px;">
            本月工单平均处理时长为 {{ avg_handle_time }}h，超时数量为 {{ overdue_orders }} 个，请关注！
        </p>
    </div>

    <!-- 二、用能概览 -->
    <div class="section">
        <div class="section-title">二、用能概览</div>
        <p>本月共计使用电力 <span class="highlight">{{ electricity_kwh }} kWh</span>，燃气 <span class="highlight">{{ gas_m3 }} m³</span>，水
            <span class="highlight">{{ water_t }} t</span>。</p>

        <h3 style="font-size: 16px; margin: 15px 0;">1. 用能报表</h3>
        <table>
            <tr>
                <th>分类</th>
                <th>数值</th>
                <th>环比</th>
                <th>同比</th>
            </tr>
            <tr>
                <td>电力</td>
                <td>{{ electricity_kwh }} kWh</td>
                <td>{{ electricity_change }}%</td>
                <td>--</td>
            </tr>
            <tr>
                <td>水</td>
                <td>--</td>
                <td>--</td>
                <td>--</td>
            </tr>
            <tr>
                <td>燃气</td>
                <td>--</td>
                <td>--</td>
                <td>--</td>
            </tr>
        </table>

        <h3 style="font-size: 16px; margin: 15px 0;">2. 用能动态</h3>
        <div class="chart-placeholder">
            [此处可嵌入 ECharts / 图表组件：电力、水、燃气动态曲线图]
        </div>
    </div>

    <!-- 三、变压器监控 -->
    <div class="section">
        <div class="section-title">三、变压器监控</div>
        <p>变压器的合理运行是用户安全用电的重要内容之一...</p>

        <h3 style="font-size: 16px; margin: 15px 0;">{{ transformer_1_name }}</h3>
        <table>
            <tr>
                <th>变压器名称</th>
                <th>额定容量(kVA)</th>
                <th>最大负载率(%)</th>
                <th>平均负载率(%)</th>
            </tr>
            <tr>
                <td>{{ transformer_1_name }}</td>
                <td>{{ transformer_1_capacity }}</td>
                <td>{{ transformer_1_max_load }}</td>
                <td>{{ transformer_1_avg_load }}</td>
            </tr>
        </table>
        <div class="chart-placeholder">
            [负载率分布图：空载/轻载/正常/重载]
        </div>
        <div class="chart-placeholder">
            [功率因数变化曲线]
        </div>
    </div>

    <!-- 四、事件统计 -->
    <div class="section">
        <div class="section-title">四、事件统计</div>
        <div class="chart-placeholder">
            [事件等级分布饼图]
        </div>
        <div class="chart-placeholder">
            [事件类型分析 TOP5 柱状图]
        </div>
        <div class="chart-placeholder">
            [事件发生位置 TOP5]
        </div>
    </div>

    <!-- 五、运维统计 -->
    <div class="section">
        <div class="section-title">五、运维统计</div>
        <div class="chart-placeholder">
            [运维类型次数统计]
        </div>
        <h3 style="font-size: 16px; margin: 15px 0;">巡检记录</h3>
        <p>· 本月共有 <span class="highlight">{{ inspection_total }}</span> 条巡检工单，其中 <span class="highlight">{{ inspection_processing }}</span>
            条处理中，<span class="highlight">{{ inspection_completed }}</span> 条已完成，<span class="highlight">{{ inspection_pending }}</span>
            条未处理。</p>

        <table style="margin-top: 10px;">
            <tr>
                <th>工单编号</th>
                <th>计划名称</th>
                <th>项目</th>
                <th>创建时间</th>
                <th>工单状态</th>
                <th>完成时间</th>
                <th>负责人</th>
                <th>任务描述</th>
            </tr>
            {{#if inspection_records}}
            {{#each inspection_records}}
            <tr>
                <td>{{ this.order_id }}</td>
                <td>{{ this.plan_name }}</td>
                <td>{{ this.project }}</td>
                <td>{{ this.create_time }}</td>
                <td>{{ this.status }}</td>
                <td>{{ this.complete_time }}</td>
                <td>{{ this.assignee }}</td>
                <td>{{ this.description }}</td>
            </tr>
            {{/each}}
            {{else}}
            <tr>
                <td colspan="8">暂无数据</td>
            </tr>
            {{/if}}
        </table>
    </div>
    <!-- 六、AI 智能建议 -->
    <div class="section">
        <div class="section-title">六、AI 智能建议</div>
        <div style="background-color: #f8f9fa; padding: 15px; border-radius: 6px; border-left: 4px solid #28a745;">
            {{#if ai_suggestion}}
            {{{ ai_suggestion }}}
            {{else}}
            <p>本月暂无 AI 建议。系统正在学习中……</p>
            {{/if}}
        </div>
        {{#if ai_model_info}}
        <p style="font-size: 12px; color: #888; margin-top: 8px;">
            💡 由 {{ ai_model_info }} 生成 | 耗时 {{ ai_generate_time }}s
        </p>
        {{/if}}
    </div>
    <div class="footer-note">
        报告生成时间：{{ generate_time }}
    </div>
</div>
</body>
</html>